package mysql

import (
	//"bluebell/models"
	"lottery/web/blue/bluebell/models"
)

func GetCommunityList() (communitys []*models.Community, err error) {
	err = db.Table("community").
		Select("community_id", "community_name").
		Find(&communitys).
		Error
	return
}

// id 查询频道社区详情
func GetCommunityDetailByID(id int64) (*models.CommunityDetail, error) {
	community := new(models.CommunityDetail)
	rst := db.Table("community").
		Select("community_id, community_name, introduction, create_time").
		Where("community_id = ?", id).
		Find(community)
	// 查询不到数据，那就说明是无效的ID
	if rst.Error != nil || rst.RowsAffected == 0 {
		return nil, ErrorInvalidID
	}
	return community, nil
}
